package net.digitalartwork.mp3player {
	import flash.display.*;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.*;
	import flash.events.*;
	import flash.text.*;
	
	import gs.TweenFilterLite;
	import gs.OverwriteManager;
	import gs.easing.*;
	
	public class PlayPauseBtn extends MovieClip{
		//--------------------------------------------------------------------------
		// ASSETS
		//--------------------------------------------------------------------------
		public var bg:MovieClip;
		public var icn_play:MovieClip;
		public var icn_pause:MovieClip;
		//--------------------------------------------------------------------------
		// DISPATCH
		//--------------------------------------------------------------------------
		public var MOUSECLICK:String = "mousedown";
		public var TOGGLE_PLAY:String = "toggleplay";
		public var TOGGLE_PAUSE:String = "togglepause";
		//--------------------------------------------------------------------------
		// PROPERTIES
		//--------------------------------------------------------------------------
		public var _w:Number;
		public var _h:Number;
		//--------------------------------------------------------------------------
		
		public function PlayPauseBtn() {
			trace("PlayPauseBtn Init");
			//--------------------------------------------------------------------------
			// 
			//--------------------------------------------------------------------------
			icn_play.mouseEnabled = false;
			icn_play.mouseChildren = false;
			
			icn_pause.mouseEnabled = false;
			icn_pause.mouseChildren = false;
			//--------------------------------------------------------------------------
			// Button BG
			//--------------------------------------------------------------------------
			bg.buttonMode = true; 
			bg.useHandCursor = true;
			bg.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler); 
			bg.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler); 
			bg.addEventListener(MouseEvent.CLICK, onClickHandler); 
			
			//bg.btn_bg_bounds.alpha = .25;
			
			TweenFilterLite.to(bg.btn_bg_bounds, .1, {colorMatrixFilter:{colorize:0x000000, amount:.5, brightness:1}});
			//--------------------------------------------------------------------------
			// Init States
			//--------------------------------------------------------------------------
			icn_pause.visible = false;
			icn_play.visible = true;
			
			icn_pause.alpha = .5;
			icn_play.alpha = .5;
			
			_w = bg.width;
			_h = bg.height;
		}
		
		private function onRollOverHandler(e:MouseEvent):void {
			//bg.btn_bg.alpha = .5;
			icn_pause.alpha = 1;
			icn_play.alpha = 1;
			//bg.btn_bg_bounds.alpha = .5;
			TweenFilterLite.to(bg.btn_bg_bounds, .1, {colorMatrixFilter:{colorize:0x000000, amount:.3, brightness:1}});
		}
		private function onRollOutHandler(e:MouseEvent):void {
			//bg.btn_bg.alpha = 1;
			icn_pause.alpha = .5;
			icn_play.alpha = .5;
			//bg.btn_bg_bounds.alpha = .25;
			TweenFilterLite.to(bg.btn_bg_bounds, .1, {colorMatrixFilter:{colorize:0x000000, amount:.5, brightness:1}});
		}
		private function onClickHandler(e:MouseEvent):void {
			dispatchEvent(new Event(MOUSECLICK));
			if (icn_play.visible == true) {
				icn_pause.visible = true;
				icn_play.visible = false;

				trace("TOGGLE_PLAY");
				dispatchEvent(new Event(TOGGLE_PLAY));
			} else {
				icn_pause.visible = false;
				icn_play.visible = true;
				trace("TOGGLE_PAUSE");
				dispatchEvent(new Event(TOGGLE_PAUSE));
			}
		}
		
	}
	
}